BITS 32

global memset
global memcpy

; void *memset(void *s, int c, size_t n)
; cdecl: s at [ebp+8], c at [ebp+12], n at [ebp+16]
memset:
    push ebp
    mov ebp, esp
    mov edi, [ebp+8]
    mov eax, [ebp+12]
    and eax, 0xFF
    mov ecx, [ebp+16]
    rep stosb
    mov eax, [ebp+8]
    pop ebp
    ret

; void *memcpy(void *dest, const void *src, size_t n)
; cdecl: dest [ebp+8], src [ebp+12], n [ebp+16]
memcpy:
    push ebp
    mov ebp, esp
    mov edi, [ebp+8]
    mov esi, [ebp+12]
    mov ecx, [ebp+16]
    rep movsb
    mov eax, [ebp+8]
    pop ebp
    ret